<%@page import="dao.Utils"%>
<%@page import="dao.ItemManager"%>
<%@page import="model.Item"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<%@include file='home.jsp'%>
	<%
	    String id = request.getParameter("itemId");
	    if (id == null)
	    {
			response.sendRedirect("items.jsp");
			return;
	    }
	    int itemId = Integer.parseInt(id);
	    ItemManager itemManager = new ItemManager();
	    Item item = itemManager.fetchItemById(itemId);
	    session.setAttribute("item", item);
	%>
	<h2>Borrow item</h2>
	<form action="borrowItem" method="post">
		<table>
			<tr>
				<td>Title:</td>
				<td><input type="text" name="title" readonly="readonly"
					value="<%=item.getTitle()%>" />
				</td>
			</tr>
			<tr>
				<td>Return date:</td>
				<td><input type="text" name="expectedReturnDate"
					value="<%=Utils.calculateReturnDate(item.getMaxPeriod())%>" />
				</td>
			</tr>
			<tr>
				<td>Username:</td>
				<td><input type="text" name="username" id="username" />
				</td>
			</tr>
			<tr>
				<td>Password:</td>
				<td><input type="password" name="password" id="password" />
				</td>
			</tr>
		</table>
		<input type="submit" value="Save changes" />
	</form>
</body>
</html>